/*
 * arrayobject.h
 *
 *  Created on: Oct 27, 2009
 *      Author: price
 */

#ifndef ARRAYOBJECT_H_
#define ARRAYOBJECT_H_

#include "templateobject.h"
#include "intnumberobject.h"
#include "realnumberobject.h"
#include "utf8stringobject.h"
#include "unicodestringobject.h"
#include "smartpointers/yasper.h"
#include <vector>

namespace templatipus
{

class TArrayObject: public TemplateObject
{

protected:
	std::vector<yasper::ptr<TemplateObject> > internalArray;

public:
	//constructor && destructor
	TArrayObject();
	TArrayObject(const TemplateObject &other);
	TArrayObject(const int8 &rhs);
	TArrayObject(const int16 &rhs);
	TArrayObject(const int32 &rhs);
	TArrayObject(const int64 &rhs);
	TArrayObject(const float32 &rhs);
	TArrayObject(const float64 &rhs);
	TArrayObject(const std::wstring& rhs);
	TArrayObject(const std::string& rhs);
	TArrayObject(const utf8Ptr rhs);
	TArrayObject(const unicodePtr rhs);

	virtual ~TArrayObject();

	//properties
	virtual TObjectType getType() const;
	virtual TIntNumberObject getLength() const;

	//methods
	virtual void add(const TemplateObject & object);
	virtual void remove(const uint64 & index);

	virtual const TemplateObject& operator +=(const TemplateObject &other);
	TArrayObject operator +(const TArrayObject &other);

	//assigning values
	virtual TemplateObject& operator=(const TemplateObject &other);
	virtual TemplateObject& operator=(const int8 &other);
	virtual TemplateObject& operator=(const int16 &other);
	virtual TemplateObject& operator=(const int32 &other);
	virtual TemplateObject& operator=(const int64 &other);
	virtual TemplateObject& operator=(const float32 &other);
	virtual TemplateObject& operator=(const float64 &other);
	virtual TemplateObject& operator=(const std::wstring& other);
	virtual TemplateObject& operator=(const std::string& other);
	virtual TemplateObject& operator=(const utf8Ptr other);
    virtual TemplateObject& operator=(const unicodePtr other);

	//comparison
	virtual tbool operator ==(const TemplateObject &other) const;
	virtual tbool operator !=(const TemplateObject &other) const;

	virtual const TemplateObject& operator [](const uint64 index);
	virtual const TemplateObject& operator [](const std::string &key);
	virtual const TemplateObject& operator [](const std::wstring &key);
	virtual const TemplateObject& operator ()(const std::string &key,const TemplateObject &params);
	virtual const TemplateObject& operator ()(const std::wstring &key,const TemplateObject &params);

	//String stuff
	virtual operator std::string() const;
	virtual operator std::wstring() const;

	//Conversion operators
	//Number
	virtual operator tbool() const;
	virtual operator int8() const;
	virtual operator uint8() const;
	virtual operator int16() const;
	virtual operator uint16() const;
	virtual operator int32() const;
	virtual operator uint32() const;
	virtual operator int64() const;
	virtual operator uint64() const;
	virtual operator float32() const;
	virtual operator float64() const;

	virtual TemplateObject * newInstance() const
	{
		return new TArrayObject();
	}

};

}

#endif /* ARRAYOBJECT_H_ */
